package com.zc.config;

import com.zc.property.SmsProperties;
import com.zc.service.SmsService;
import com.zc.service.impl.SmsServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @description:
 * @author: cong
 * @create: 2024/7/18
 */
@Configuration
@EnableConfigurationProperties(SmsProperties.class)
@ConditionalOnProperty(prefix = "sms", name = "enable", havingValue = "true")
public class SmsConfig {
    @Autowired
    private SmsProperties smsProperties;

    @Bean
    public SmsService smsService() {
        System.out.println("加载了Bean：smsService");
        return new SmsServiceImpl(smsProperties);
    }
}
